﻿<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title>日照分析</title>
    <link rel="stylesheet" href="../../Workers/layui/css/layui.css" rel="stylesheet" />
    <style>
        html {
            overflow: hidden;
            height: 100%;
        }
        .laydate-btns-clear{
          display: none;  
        }
        .dateBox {
            height: 300px;
            overflow: auto;
            margin-right: 6px;
        }

        .dateBox::-webkit-scrollbar {
            /*滚动条整体样式*/
            width: 4px;
            /*高宽分别对应横竖滚动条的尺寸*/
            height: 4px;
            scrollbar-arrow-color: red;
        }

        .dateBox::-webkit-scrollbar-thumb {
            border-radius: 5px;
            -webkit-box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.2);
            box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.2);
            background: rgba(255, 255, 255, 0.5);
            scrollbar-arrow-color: red;
        }

        .dateBox::-webkit-scrollbar-track {
            -webkit-box-shadow: inset 0 0 5px rgba(218, 218, 218, 0.2);
            box-shadow: inset 0 0 5px rgba(218, 218, 218, 0.2);
            border-radius: 0;
            background: rgba(218, 218, 218, 0.1);
        }

        .dateBox label {
            color: white;
        }

        .bnt-box {
            width: 90%;
            margin: auto;
            height: 58px;
            border-bottom: 1px #999 solid;
        }

        .layui-input {
            background-color: #fff !important;
            width: 203px
        }

        .layui-form-label {
            font-weight: bold !important;
            font-size: 15px;
        }

        .layui-btn {
            background-color: rgba(0, 168, 255, 0.16) !important;
        }
    </style>
</head>

<body>
    <div class="dateBox">
        <div class="layui-inline" style="margin-top: 15px">
            <label class="layui-form-label">日期选择</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="date" placeholder="yyyy-MM-dd">
            </div>
        </div>
        <div class="layui-inline" style="margin-top: 15px">
            <label class="layui-form-label">开始时间</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="startTime" placeholder="HH:mm:ss">
            </div>
        </div>
        <div class="layui-inline" style="margin-top: 15px">
            <label class="layui-form-label">结束时间</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="endTime" placeholder="HH:mm:ss">
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 15px">
            <label class="layui-form-label" style="font-weight: bold">时间间隔</label>
            <div class="layui-input-inline">
                <input id='interval' type="number" lay-verify="pass" value="60" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 15px">
            <label class="layui-form-label" style="font-weight: bold">空间间隔</label>
            <div class="layui-input-inline">
                <input id='spacing' type="number" lay-verify="pass" value="10" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 15px">
            <label class="layui-form-label" style="font-weight: bold">拉伸高度</label>
            <div class="layui-input-inline">
                <input id='addHeight' type="number" lay-verify="pass" value="30" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="buttonContainer" style="text-align: center;">
            <button type="button" class="layui-btn layui-btn-normal analyse" style="padding: 0 38px;">
                开始分析
            </button>
        </div>

    </div>

    <script src="../jquery-2.0.3.js"></script>
    <script src="../../Workers/layui/layui.js"></script>
    <script>
        $(function () {
            layui.use(['element', 'form', 'laydate'], function () {
                var $ = layui.jquery
                    , element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
                var form = layui.form;
                var laydate = layui.laydate;
                var sgworld = parent.sgworld;
                var Viewer = parent.Viewer;
                var Cesium = parent.Cesium;
                var layer = parent.layuiLayer;

                let date = new Date();
                date = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                let startTime = '13:00:00', stopTime = '15:00:00';

                let interval = 60, spacing = 10, addHeight = 30;

                laydate.render({
                    elem: '#date'
                    , format: 'yyyy-MM-dd'
                    , value: new Date()
                    , done: function (value, _date, endDate) {
                        date = value;
                    }
                });
                laydate.render({
                    elem: '#startTime'
                    , format: 'HH:mm:ss'
                    , type: 'time'
                    , value: '13:00:00'
                    , done: function (value, _date, endDate) {
                        let sNum = new Date(date + ' ' + value).getTime() / 1000;
                        let eNum = new Date(date + ' ' + stopTime).getTime() / 1000;
                        if (sNum > eNum) {
                            layer.msg('开始时间大于结束时间，请重新选择');
                            return;
                        }
                        startTime = value;
                    }
                });
                laydate.render({
                    elem: '#endTime'
                    , format: 'HH:mm:ss'
                    , value: '15:00:00'
                    , type: 'time'
                    , done: function (value, _date, endDate) {
                        let sNum = new Date(date + ' ' + startTime).getTime() / 1000;
                        let eNum = new Date(date + ' ' + value).getTime() / 1000;
                        if (sNum > eNum) {
                            layer.msg('开始时间大于结束时间，请重新选择');
                            return;
                        }
                        stopTime = value;
                    }
                });

                $('.analyse').click(function () {
                    parent.window._AnalysisSunshine = sgworld.Analysis.SunshineAnalysisPolygon({
                        start: date + ' ' + startTime,
                        end: date + ' ' + stopTime,
                        interval: interval,
                        spacing: spacing,
                        addHeight: addHeight
                    });
                })

                $('#interval').on('input propertychange', function (event) {
                    let value = parseFloat(this.value);
                    if (!isNaN(value)) {
                        interval = value;
                    }
                });
                $('#spacing').on('input propertychange', function (event) {
                    let value = parseFloat(this.value);
                    if (!isNaN(value)) {
                        spacing = value;
                    }
                })
                $('#addHeight').on('input propertychange', function (event) {
                    let value = parseFloat(this.value);
                    if (!isNaN(value)) {
                        addHeight = value;
                    }
                })
            });
        })
    </script>
</body>

</html>